package edu.scau.ojforwarder.util;

import edu.scau.ojforwarder.bean.BaseResult;
import edu.scau.ojforwarder.bean.IError;

public class ResultGenerator {

    public static <T> BaseResult<T> genResult(IError error, T data) {
        BaseResult<T> result = new BaseResult<>();
        result.setCode(error.getCode());
        result.setMsg(error.getMsg());
        result.setData(data);
        return result;
    }

    public static <T> BaseResult<T> genResult(IError error) {
        return genResult(error, null);
    }
}
